package com.yanqu.road.server.manager.activity.xingyou.inter.grid;

import com.yanqu.road.entity.activity.youxing.CrossXingYouShanShuiUserData;
import com.yanqu.road.entity.activity.youxing.ShanShuiGridParam;
import com.yanqu.road.entity.activity.youxing.config.XingYouShanShuiGridInfo;
import com.yanqu.road.logic.helper.RandomWeightConfigHelper;
import com.yanqu.road.pb.activity.XingYouShanShuiProto;
import com.yanqu.road.server.manager.activity.xingyou.CrossXingYouActivity;
import com.yanqu.road.server.manager.activity.xingyou.DiceHandleResult;
import com.yanqu.road.server.manager.activity.xingyou.inter.GridHandleResult;
import com.yanqu.road.server.manager.activity.xingyou.inter.IXingYouGridHandler;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;
import com.yanqu.road.utils.string.StringUtils;

/**
 * 空白格
 */
public class EmptyGridHandler implements IXingYouGridHandler {

    @Override
    public void handle(XingYouShanShuiGridInfo gridInfo, int pos, int gridId, int endPos, boolean fly, DiceHandleResult result) {
        //是否停留
        boolean stop = pos == endPos;
        if (stop) {

            CrossXingYouActivity activity = result.getActivity();

            Property reward = new Property();
            Property fixedReward = result.getActivity().getGridInfoFixedReward(result.getUserData(), gridInfo, true);
            reward.addProperty(fixedReward);

            activity.calRewardBuff(result.getUserData(), reward, false, 0);

            XingYouShanShuiProto.ShanShuiEventInfo.Builder eventBuilder = activity.getEventInfoBuilder(pos, gridId, reward, true);
            eventBuilder.setBaseReward(PropertyHelper.parsePropertyToString(fixedReward));

            eventBuilder.setFixedReward(PropertyHelper.parsePropertyToString(fixedReward));

            GridHandleResult gridHandleResult = new GridHandleResult();
            ShanShuiGridParam gridParam = new ShanShuiGridParam(gridId, pos, true, result.getUserData().isDrift());
            gridHandleResult.setGridParam(gridParam);
            gridHandleResult.setBuilder(eventBuilder);
            result.getGridHandleResultList().add(gridHandleResult);

            CrossXingYouShanShuiUserData userData = result.getUserData();
            //是否有捕快
            result.getActivity().tryCatch(pos, userData, result, gridHandleResult);
        }
    }
}
